home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / term.48 < prev    next >
Internet Message Format  |  1990-09-14  |  8KB

  1. From helens!shelby!decwrl!elroy.jpl.nasa.gov!sdd.hp.com!samsung!zaphod.mps.ohio-state.edu!usc!ucsd!ucbvax!hplabs!hpda!hpcupt1!jodell Wed Jul 11 15:03:28 PDT 1990
  2. Status: RO
  3.  
  4. Article 2132 of comp.sys.handhelds:
  5. Path: helens!shelby!decwrl!elroy.jpl.nasa.gov!sdd.hp.com!samsung!zaphod.mps.ohio-state.edu!usc!ucsd!ucbvax!hplabs!hpda!hpcupt1!jodell
  6. >From: jodell@hpcupt1.HP.COM (Jamie Odell)
  7. Newsgroups: comp.sys.handhelds
  8. Subject: Power of 48 from your PC
  9. Message-ID: <10490013@hpcupt1.HP.COM>
  10. Date: 11 Jul 90 01:01:46 GMT
  11. Organization: Hewlett Packard, Cupertino
  12. Lines: 194
  13.  
  14. Several people have mentioned the lack of support for "Using the Power of Your
  15. HP-48sx from your PC" in the cable/software package.  In order to help bridge
  16. that gap - and mostly because I can't type long programs on the 48's keyboard
  17. - I have written a program that allows object entry from a terminal or
  18. terminal emulator.  This program works, but it is far from complete.  I wrote
  19. it basically to see if I could do it.  I hope that someone can get some good
  20. use out of it.
  21.  
  22.  
  23. Purpose: This program will allow a user to type objects on a terminal (or
  24. terminal emulator directly to the HP-48sx.
  25.  
  26. Directions for use: Download the directory TERM.  Setup your IOPAR variable
  27. for XON XOFF and for whatever other communication parameters you want to use.
  28. For example: for 9600 baud, no parity checking, and XON XOFF - your IOPAR
  29. variable could be { 9600 0 1 1 3 1 }.  Note that the translate code, and
  30. checksum type are not used.
  31.  
  32. Connect the 48sx to your terminal or PC and set up the communication
  33. parameters on both the 48 and PC. Make TERM the current directory, and execute
  34. TRM.  You should see:
  35.                 Term Entry 1.0
  36. on your terminal screen, as well as on the 48sx screen.
  37.  
  38. Now you can type things on your terminal.  Each character is sent to the 48.
  39. To tell the 48 that you are finished with the current object, type END on a
  40. line by itself.
  41.  
  42. All the lines you have typed so far will be combined into an object and left
  43. on the stack.
  44.  
  45. The backspace key (Control-H) will delete the last character you typed on a
  46. current line.  This is the only form of editing allowed.
  47.  
  48. To enter the symbols "<<", ">>", or "->" you should type \<<, \>>, \->
  49. respectively.  The program automatically takes care of converting the symbols.
  50.  
  51. Since this program uses XMIT and SRECV for I/O, the translate code in IOPAR is
  52. not used.  This means that \<<, \>>, and \-> will be the only symbols
  53. converted.
  54.  
  55. Please note that this is the 1.0 version of this program.  I wrote it quickly
  56. because I wanted to be able to use a typewriter keyboard to enter data into
  57. the 48.  I have some ideas for enhancements such as better editing
  58. capabilities, two way data transfer, more control of the 48 from a terminal,
  59. etc.  If I get the chance, I'll add some of these features.
  60.  
  61. Also, and this is VERY IMPORTANT.  This code expects the stack to be empty
  62. before it is run.  I know this is not good calculator programming etiquette,
  63. but hey, I'll fix it in a later release. As you've probably guessed, I'm a
  64. software engineer :-)
  65.  
  66. Feel free to do whatever you want to this code.  Please let me know if you
  67. make any cool enhancements.
  68.  
  69. The directory contains the following objects:
  70.  
  71. TRM - Main entry point to this program.  This saves the current flags, prints
  72. "Term Entry 1.0" on the 48's display, and calls GETPROG.  Flag 2 is set. Flag
  73. 2 does not mean anything.  It was supposed to mean that the program should
  74. echo characters back to the terminal.   The program always echos characters to
  75. the terminal, so flag 2 doesn't do anything.  I should remove it, but I
  76. haven't yet.
  77.  
  78. GETPROG - Get a program (or any object).  This procedure opens I/O
  79. communications, clears the I/O buffer, and sends "Term Entry 1.0" to the
  80. Terminal.  Then it collects lines of text, until the user types "END".
  81. Afterwards, it combines all the lines of text into a single object and leaves
  82. it on the stack.
  83.  
  84. READLN - Reads a line of text.  A line is a string of characters terminated
  85. with a carriage return.
  86.  
  87. FIXLN - Convert \<<, \>>, \-> into their 48sx representations everywhere they
  88. appear in a line.
  89.  
  90. CNVR - Convert all the strings on the stack (lines) into one object.
  91.  
  92. READCH - Read a single character from the terminal, and add it to the current
  93. string.  If the character is a backspace, then erase one character from the
  94. string.  If the character is a carriage return, then echo a carriage return,
  95. line feed sequence.
  96.  
  97. DECL - Remove one character from the current line.
  98.  
  99. LIN - Current line is stored here.  When the line is terminated, it gets
  100. pushed as a string onto the stack.
  101.  
  102. Jamie Odell
  103. MXO - Commercial Systems Division (CSY)
  104. Hewlett-Packard Co.
  105. jodell@hpda.hp.com
  106.  
  107. ------------------------------------------------------------------------------
  108. #FD90h 953
  109. %%HP: T(3)A(D)F(.);
  110. DIR
  111.   TRM
  112.     \<< CLLCD
  113. "Term Entry 1.0" 1
  114. DISP RCLF \-> f
  115.       \<< 2 SF             @ Set terminal echo on (not used!).
  116. GETPROG f STOF
  117.       \>>
  118.     \>>
  119.   GETPROG
  120.     \<< OPENIO BUFLEN
  121. DROP SRECV DROP            @ Clear the serial I/O buffer before doing anything
  122. DROP
  123. "Term Entry 1.0" 13
  124. CHR + 10 CHR + XMIT        @ Transmit message with CR/LF
  125. DROP
  126.       DO READLN LIN        @ Read in next line
  127. FIXLN                      @ Convert special characters to 48 characters
  128.       UNTIL LIN
  129. "END" 13 CHR + SAME        @ Loop until user types END on a line by itself
  130. "" 'LIN' STO
  131.       END CNVRT            @ Pack all lines into a single object
  132.     \>>
  133.   READLN
  134.     \<<
  135.       DO READCH DUP        @ Read characters until CR
  136. 'LIN' SWAP STO+
  137.       UNTIL 13 CHR
  138. SAME LIN 2 DISP
  139.       END
  140.     \>>
  141.   FIXLN     
  142.     \<< \-> l
  143.       \<< 1 CF             @ Check for occurences of \<< \>> \->
  144.         DO l
  145.           CASE l           @ Loop until no more occurences are found,
  146. "\\<<" POS                 @ converting each occurence on the way to the 48
  147.             THEN l         @ representation.
  148. "\\<<" POS "\<<  "         @
  149. REPL                       @ More special characters can be added as needed.
  150.             END l          @ Just add a new case.
  151. "\\>>" POS                 @ Remember to replace the number of characters you
  152.             THEN l         @ remove with an identical number of characters.
  153. "\\>>" POS "  \>>"        
  154. REPL
  155.             END l
  156. "\\->" POS
  157.             THEN l
  158. "\\->" POS "\->  "
  159. REPL
  160.             END 1
  161. SF
  162.           END 'l'
  163. STO
  164.         UNTIL 1 FS?       @ Flag 1 is a boolean used to tell us if we are done
  165.         END l
  166.       \>>
  167.     \>>
  168.   CNVRT
  169.     \<< DROP "" DEPTH     @ Drop the "END" string off the stack
  170. \-> d
  171.       \<<
  172.         IF d 1 >          @ Combine everything on the stack into one string
  173.         THEN 2 d
  174.           START +
  175.           NEXT
  176.         END OBJ\->        @ Convert the string into an object
  177.       \>>
  178.     \>>
  179.   READCH
  180.     \<<
  181.       DO                  @ Wait until the user types a key on the terminal
  182.       UNTIL BUFLEN
  183. DROP 0 >
  184.       END 1 SRECV         @ Get one character at a time!
  185. DROP \-> c
  186.       \<<
  187.         CASE c 13         @ If the character is a return then echo CR/LF
  188. CHR SAME
  189.           THEN c 10
  190. CHR + XMIT DROP c
  191.           END c 8         @ If the character is a backspace, then erase the
  192. CHR SAME                  @ character from the terminal, and remove it from
  193.           THEN c          @ the current line.
  194. " " + c + XMIT DROP
  195. DECLN ""
  196.           END c
  197. XMIT DROP c               @ Otherwise, just echo the character.
  198.         END
  199.       \>>
  200.     \>>
  201.   DECLN
  202.     \<< LIN 1 LIN 
  203. SIZE 1 - SUB 'LIN'
  204. STO
  205.     \>>
  206.   LIN ""
  207. END
  208.  
  209.  
  210.